package com.retrofit.demo.service;

import com.retrofit.demo.entity.MovieEntity;
import com.retrofit.demo.entity.ResponseBody;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 *
 * <h3>Description</h3>
 * TODO
 * <h3>Author</h3> Louis
 * <h3>Date</h3> 2018/7/14 18:17
 * <h3>Copyright</h3> Copyright (c) 2018 Shenzhen ChinaSoft International Co., Ltd. Inc. All rights reserved.
 */
public interface MovieService {

    //https://api.douban.com/v2/movie/top250?start=0&count=10
    @GET("top250")
    Call<MovieEntity> getMovieList(@Query("start") int start , @Query("count") int count);


    /**
     * 表明是一个表单格式的请求（Content-Type:application/x-www-form-urlencoded）
     * Field : 参数名为 userName
     * @return
     */
    @POST("/form")
    @FormUrlEncoded
    Call<ResponseBody> testFormUrlEncode(@Field("userName") String userName);


    /**
     * {@link Part} 后面支持三种类型，{@link RequestBody}、{@link okhttp3.MultipartBody.Part} 、任意类型
     * 除 {@link okhttp3.MultipartBody.Part} 以外，
     * 其它类型都必须带上表单字段({@link okhttp3.MultipartBody.Part} 中已经包含了表单字段的信息)，
     * @param name
     * @return
     */
    @POST("/form")
    @Multipart
    Call<ResponseBody> testMuiltpart(@Part ("name")RequestBody name,@Part MultipartBody.Part file);


    @POST("translate?doctype=json&jsonversion=&type=&keyfrom=&model=&mid=&imei=&vendor=&screen=&ssid=&network=&abtest=")
    @FormUrlEncoded
    Call<ResponseBody> testTranslate(@Field("i") String s);




    @GET("top250")
    Observable<MovieEntity> getMovieList2(@Query("start") int start , @Query("count") int count);


}
